﻿@page
@{ Layout = "_Layout"; }
@section Styles{
  <style>
    .commands div { display: inline-block; width: auto; }
    .el-upload, .el-upload-dragger { display: inline-block; width: auto; }
    .el-icon-arrow-down {
      font-size: 12px;
    }
    .el-icon-picture-outline {
      font-size: 22px;
      margin: 80px 0;
      color: #c0c4cc;
    }
    .el-card-wrapper {
      padding-bottom: 15px; 
      padding-right: 15px; 
      width: 25%; 
      box-sizing: border-box;
      display: inline-block;
      vertical-align: top;
    }

    .thumb {
      padding: 10px;
    }
    .thumb .cover {
      cursor: pointer; 
      position: relative; 
      height:150px; 
      background-size: cover;
      background-position: 50% 50%;
      background-repeat: no-repeat;
      background-color: #f6f8f9;
    }
    .thumb .cover .text {
      position: absolute;
      bottom: 0;
      text-align: center;
      display: block;
      width: 100%;
      color: #fff;
      padding: 6px;
      background-color: rgba(202, 195, 195, 0.28);;
    }
    .list {
      padding: 10px;
      cursor: pointer;
    }
    .thumb:hover, .active, .list:hover {
      background: rgb(225, 243, 216);
    }
    .list .text {
      text-align: left;
      font-size: 14px;
      height: 38px;
      overflow: hidden;
    }
  </style>
}

<el-row>
  <el-col :span="12">
    <el-form v-on:submit.native.prevent :inline="true" :model="form" size="mini">
      <el-form-item label="搜索">
        <el-input v-model="form.keyword" placeholder="关键字"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" v-on:click="btnSearchClick">查询</el-button>
      </el-form-item>
    </el-form>
  </el-col>
  <el-col class="commands" align="right" :span="12">

    <el-radio-group v-model="showType" plain size="small">
      <el-radio-button label="card">卡片视图</el-radio-button>
      <el-radio-button label="list">列表视图</el-radio-button>
    </el-radio-group>

  </el-col>
</el-row>

<el-form v-on:submit.native.prevent :inline="true" :model="form">
  <el-form-item label="分组">

    <el-tag
      v-for="group in groups"
      :key="group.id"
      type="success"
      style="cursor: pointer; margin: 0 3px 6px 0;"
      v-on:click="btnGroupClick(group.id)"
      :effect="form.groupId === group.id ? 'dark' : 'plain'">
      {{ group.groupName }}
    </el-tag>
   
  </el-form-item>
</el-form>

<div>
  <template v-if="showType === 'card'">

    <template  v-for="(message, index) in messages" :key="message.id" v-if="message.items && message.items.length >= 1">
      <div class="el-card-wrapper" v-if="message.items.length === 1">
        <el-card :body-style="{ padding: '0px', textAlign: 'center' }">
          <div slot="header" class="clearfix">
            <el-tooltip :content="message.items[0].title" placement="top">
              <span style="text-overflow: ellipsis; display: block; width: 100%; white-space: nowrap; overflow: hidden;">{{ message.items[0].title }}</span>
            </el-tooltip>
          </div>
          <a href="javascript:;" v-on:click="btnMessageClick(message)">
            <el-image 
              style="width: 100%; min-height: 220px; max-height:220px;"
              :src="message.items[0].thumbUrl">
              <div slot="error" class="image-slot">
                <i class="el-icon-picture-outline"></i>
              </div>
            </el-image>
          </a>
          <div style="padding: 14px;">
            <div style="cursor: pointer; font-size: 14px; text-overflow: ellipsis; width: 100%; max-height: 95px; overflow: hidden;">
              {{ message.items[0].digest }}
            </div>
  
            <el-divider></el-divider>
  
            <el-row align="left" style="margin-top: 10px;font-size: 14px; color: #999; padding-top: 3px">
              更新于 {{ utils.getFriendlyDateTime(message.lastModifiedDate) }}
            </el-row>
            
          </div>
        </el-card>
      </div>
      <div class="el-card-wrapper" v-else>
        <el-card :body-style="{ padding: '0px', textAlign: 'center' }">
          <template v-for="(item, index) in message.items" :key="index">
            <div v-if="index === 0" v-on:click="btnMessageClick(message)" class="thumb">
              <div class="cover" :style="{backgroundImage: 'url(' + item.thumbUrl + ')'}">
                <div class="text">{{item.title}}</div>
              </div>
            </div>
            <div v-else v-on:click="btnMessageClick(message)" class="list">
              <el-row>
                <el-col span="18">
                  <div class="text">{{item.title}} {{item.index}}</div>
                </el-col>
                <el-col span="6">
                  <el-image 
                    fit="cover"
                    style="width: 55px; height: 55px"
                    :src="item.thumbUrl">
                    <div slot="error" class="image-slot">
                      <i class="el-icon-picture-outline" style="margin: 0px; font-size: 36px; color: #999; background: #fff; padding: 5px;"></i>
                    </div>
                  </el-image>
                </el-col>
              </el-row>
            </div>
            
            <el-divider></el-divider>
          </template>
  
          <el-row align="left" style="padding: 10px;margin-bottom: 5px; font-size: 14px; color: #999; padding-top: 3px">
            更新于 {{ utils.getFriendlyDateTime(message.lastModifiedDate) }}
          </el-row>
  
        </el-card>
      </div>
    </template>
  
  </template>
  <template v-else>
    <el-table
      :data="messages"
      style="width: 100%">
      <el-table-column
        label="封面"
        width="140">
        <template slot-scope="scope">
          <el-link :underline="false" v-on:click="btnMessageClick(scope.row)">
            <img :src="scope.row.items[0].thumbUrl" style="max-height: 120px; max-width: 120px;"/>
          </el-link>
        </template>
      </el-table-column>
      <el-table-column label="内容">
        <template slot-scope="scope">
          <div v-html="getFriendlyContent(scope.row)"></div>
        </template>
      </el-table-column>
      <el-table-column
        prop="lastModifiedDate"
        label="更新于"
        width="160">
        <template slot-scope="scope">
          {{ utils.getFriendlyDateTime(scope.row.lastModifiedDate) }}
        </template>
      </el-table-column>
    </el-table>
  </template>
</div>

<el-divider></el-divider>
<el-row style="margin: 10px;">
  <el-col :span="20" align="left">
    <div style="text-align: left;">
      <el-pagination
        v-on:current-change="btnPageClick"
        :current-page="form.page"
        :page-size="form.perPage"
        layout="total, prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>
  </el-col>
  <el-col :span="4" align="right">
    <el-button size="small" v-on:click="btnCancelClick">取 消</el-button>
  </el-col>
</el-row>

@section Scripts{
<script src="/sitefiles/assets/js/admin/wx/layerMessage.js" type="text/javascript"></script> }